package com.test.ssm.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.test.ssm.dao.AccountDAO;
import com.test.ssm.pojo.Account;
import com.test.ssm.pojo.Role;
import com.test.ssm.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AccountServiceImpl implements AccountService {
    @Autowired
    private AccountDAO accountDAO;

    @Override
    public Account getPasswordByName(String name) {
        return accountDAO.getPasswordByName(name);
    }

    @Override
    public PageInfo<Account> getAccountList(Account account, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Account> accountList = accountDAO.getAccountList(account);
        return new PageInfo<>(accountList);
    }

    @Override
    public Account getAccountById(Account account) {
        return accountDAO.getAccountById(account);
    }

    @Override
    public int deleteUser(Integer id) {
        int i = accountDAO.deleteUser(id);
        return i;
    }

    @Override
    public int addAccount(Account account) {
        return accountDAO.addAccount(account);
    }

    @Override
    public int updateAccount(Account account) {
        return accountDAO.updateAccount(account);
    }
}
